package com.example.villagedevelop.generator.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.villagedevelop.generator.entity.ImageCase;
import com.example.villagedevelop.generator.entity.ImageHouse;
import com.example.villagedevelop.generator.mapper.ImageHouseMapper;
import com.example.villagedevelop.generator.service.ImageHouseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author villagedevelop
 * @since 2021-11-13
 */
@Service
public class ImageHouseServiceImpl extends ServiceImpl<ImageHouseMapper, ImageHouse> implements ImageHouseService {
    @Autowired
    ImageHouseMapper mapper;

    //根据hid查找images
    @Override
    public List<String> getImagesByHid(Integer hid) {
        List<String> imagess = new ArrayList<>();
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("h_id",hid);
        List<ImageHouse> images= mapper.selectList(wrapper);
        for (ImageHouse image : images){
            imagess.add(image.getImageFile());
        }
        return imagess;
    }


    //废弃
    @Override
    public List<String> getUrlImages(int hid) {
        List<String> urlList = new ArrayList<>();
        for (String image: this.getImagesByHid(hid)){
            image = "https://abc.moreday.top/image/"+image;
            urlList.add(image);
        }

        return urlList;
    }

}
